home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Amiga Public Domain Connection / APDC Disk #025 - Programming Languages (198x)(Amiga Public Domain Connection)(US)[WB].zip / APDC Disk #025 - Programming Languages (198x)(Amiga Public Domain Connection)(US)[WB].adf / XLisp.Doc < prev   
Text File  |  1988-03-15  |  62KB  |  1,471 lines

  1.                 XLISP: An Experimental Object-oriented Language
  2.  
  3.                                   Version 1.7
  4.  
  5.                                   June 2, 1986
  6.  
  7.                                        by
  8.                                David Michael Betz
  9.                                114 Davenport Ave.
  10.                              Manchester, NH  03103
  11.  
  12.                              (603) 625-4691 (home)
  13.  
  14.                    Copyright (c) 1986, by David Michael Betz
  15.                               All Rights Reserved
  16.            Permission is granted for unrestricted non-commercial use
  17.  
  18.  
  19.         XLISP                  TABLE OF CONTENTS                  Page 2
  20.  
  21.  
  22.                 TABLE OF CONTENTS                        2
  23.  
  24.                 INTRODUCTION                             4
  25.  
  26.                 A NOTE FROM THE AUTHOR                   5
  27.  
  28.                 XLISP COMMAND LOOP                       6
  29.  
  30.                 BREAK COMMAND LOOP                       7
  31.  
  32.                 DATA TYPES                               8
  33.  
  34.                 THE EVALUATOR                            9
  35.  
  36.                 LEXICAL CONVENTIONS                     10
  37.  
  38.                 READTABLES                              11
  39.  
  40.                 OBJECTS                                 12
  41.  
  42.                 SYMBOLS                                 15
  43.  
  44.                 EVALUATION FUNCTIONS                    16
  45.  
  46.                 SYMBOL FUNCTIONS                        17
  47.  
  48.                 PROPERTY LIST FUNCTIONS                 19
  49.  
  50.                 ARRAY FUNCTIONS                         20
  51.  
  52.                 LIST FUNCTIONS                          21
  53.  
  54.                 DESTRUCTIVE LIST FUNCTIONS              24
  55.  
  56.                 PREDICATE FUNCTIONS                     25
  57.  
  58.                 CONTROL CONSTRUCTS                      27
  59.  
  60.                 LOOPING CONSTRUCTS                      29
  61.  
  62.                 THE PROGRAM FEATURE                     30
  63.  
  64.                 DEBUGGING AND ERROR HANDLING            31
  65.  
  66.                 ARITHMETIC FUNCTIONS                    32
  67.  
  68.                 BITWISE LOGICAL FUNCTIONS               34
  69.  
  70.                 RELATIONAL FUNCTIONS                    35
  71.  
  72.                 STRING FUNCTIONS                        36
  73.  
  74.         XLISP                  TABLE OF CONTENTS                  Page 3
  75.  
  76.                 INPUT/OUTPUT FUNCTIONS                  37
  77.  
  78.                 FILE I/O FUNCTIONS                      38
  79.  
  80.                 SYSTEM FUNCTIONS                        39
  81.  
  82.                 EXAMPLES                                41
  83.  
  84.  
  85.  
  86.         XLISP                     INTRODUCTION                    Page 4
  87.  
  88.  
  89.         INTRODUCTION
  90.  
  91.         XLISP is an experimental programming language combining some of
  92.         the features of LISP with an object-oriented extension
  93.         capability.  It was implemented to allow experimentation with
  94.         object-oriented programming on small computers.  There are
  95.         currently implementations running on the the VAX under VAX/VMS,
  96.         on the 8088/8086 under MS-DOS, on the 68000 under CP/M-68K, on
  97.         the Macintosh, on the Atari 520ST and on the Amiga.  It is
  98.         completely written in the programming language 'C' and is easily
  99.         extended with user written built-in functions and classes.  It
  100.         is available in source form free of charge to non-commercial
  101.         users.
  102.  
  103.         Many traditional LISP functions are built into XLISP.  In
  104.         addition, XLISP defines the objects 'Object' and 'Class' as
  105.         primitives.  'Object' is the only class that has no superclass
  106.         and hence is the root of the class heirarchy tree.  'Class' is
  107.         the class of which all classes are instances (it is the only
  108.         object that is an instance of itself).
  109.  
  110.         This document is a brief description of XLISP.  It assumes some
  111.         knowledge of LISP and some understanding of the concepts of
  112.         object-oriented programming.
  113.  
  114.         A recommended text for learning LISP programming is the book
  115.         "LISP" by Winston and Horn and published by Addison Wesley.  The
  116.         first edition of this book is based on MacLisp and the second
  117.         edition is based on Common Lisp.  Future versions of XLISP will
  118.         continue to migrate towards compatibility with Common Lisp.
  119.  
  120.  
  121.         XLISP                A NOTE FROM THE AUTHOR               Page 5
  122.  
  123.         A NOTE FROM THE AUTHOR
  124.  
  125.         If you have any problems with XLISP, feel free to contact me for
  126.         help or advice.  Please remember that since XLISP is available
  127.         in source form in a high level language, many users have been
  128.         making versions available on a variety of machines.  If you call
  129.         to report a problem with a specific version, I may not be able
  130.         to help you if that version runs on a machine to which I don't
  131.         have access.  Please have the version number of the version that
  132.         you are running readily accessible before calling me.
  133.  
  134.         If you find a bug in XLISP, first try to fix the bug yourself
  135.         using the source code provided.  If you are successful in fixing
  136.         the bug, send the bug report along with the fix to me.  If you
  137.         don't have access to a C compiler or are unable to fix a bug,
  138.         please send the bug report to me and I'll try to fix it.
  139.  
  140.         Any suggestions for improvements will be welcomed.  Feel free to
  141.         extend the language in whatever way suits your needs.  However,
  142.         PLEASE DO NOT RELEASE ENHANCED VERSIONS WITHOUT CHECKING WITH ME
  143.         FIRST!!  I would like to be the clearing house for new features
  144.         added to XLISP.  If you want to add features for your own
  145.         personal use, go ahead.  But, if you want to distribute your
  146.         enhanced version, contact me first.  Please remember that the
  147.         goal of XLISP is to provide a language to learn and experiment
  148.         with LISP and object-oriented programming on small computers.  I
  149.         don't want it to get so big that it requires megabytes of memory
  150.         to run.
  151.  
  152.  
  153.         XLISP                 XLISP COMMAND LOOP                  Page 6
  154.  
  155.  
  156.         XLISP COMMAND LOOP
  157.         When XLISP is started, it first tries to load "init.lsp" from
  158.         the default directory.  It then loads any files named as
  159.         parameters on the command line (after appending ".lsp" to their
  160.         names).  It then issues the following prompt:
  161.  
  162.         >
  163.  
  164.         This indicates that XLISP is waiting for an expression to be
  165.         typed.  When an incomplete expression has been typed (one where
  166.         the left and right parens don't match) XLISP changes its prompt
  167.         to:
  168.  
  169.         n>
  170.  
  171.         where n is an integer indicating how many levels of left parens
  172.         remain unclosed.
  173.  
  174.         When a complete expression has been entered, XLISP attempts to
  175.         evaluate that expression.  If the expression evaluates
  176.         successfully, XLISP prints the result of the evaluation and then
  177.         returns to the initial prompt waiting for another expression to
  178.         be typed.
  179.  
  180.  
  181.         XLISP                 BREAK COMMAND LOOP                  Page 7
  182.  
  183.         BREAK COMMAND LOOP
  184.  
  185.         When XLISP encounters an error while evaluating an expression,
  186.         it attempts to handle the error in the following way:
  187.  
  188.         If the symbol '*breakenable*' is true, the message corresponding
  189.         to the error is printed.  If the error is correctable, the
  190.         correction message is printed.  If the symbol '*tracenable*' is
  191.         true, a trace back is printed.  The number of entries printed
  192.         depends on the value of the symbol '*tracelimit*'.  If this
  193.         symbol is set to something other than a number, the entire trace
  194.         back stack is printed.  XLISP then enters a read/eval/print loop
  195.         to allow the user to examine the state of the interpreter in the
  196.         context of the error.  This loop differs from the normal top-
  197.         level read/eval/print loop in that if the user invokes the
  198.         function 'continue', XLISP will continue from a correctable
  199.         error.  If the user invokes the function 'clean-up', XLISP will
  200.         abort the break loop and return to the top level or the next
  201.         lower numbered break loop.  When in a break loop, XLISP prefixes
  202.         the break level to the normal prompt.
  203.  
  204.         If the symbol '*breakenable*' is nil, XLISP looks for a
  205.         surrounding errset function.  If one is found, XLISP examines
  206.         the value of the print flag.  If this flag is true, the error
  207.         message is printed.  In any case, XLISP causes the errset
  208.         function call to return nil.
  209.  
  210.         If there is no surrounding errset function, XLISP prints the
  211.         error message and returns to the top level.
  212.  
  213.  
  214.         XLISP                      DATA TYPES                     Page 8
  215.  
  216.         DATA TYPES
  217.  
  218.         There are several different data types available to XLISP
  219.         programmers.
  220.  
  221.             o lists
  222.             o symbols
  223.             o strings
  224.             o integers
  225.             o floats
  226.             o objects
  227.             o arrays
  228.             o file pointers
  229.             o subrs (built-in functions)
  230.             o fsubrs (special forms)
  231.  
  232.         Another data type is the stream.  A stream is a list node whose
  233.         car points to the head of a list of integers and whose cdr
  234.         points to the last list node of the list.  An empty stream is a
  235.         list node whose car and cdr are nil.  Each of the integers in
  236.         the list represents a character in the stream.  When a character
  237.         is read from a stream, the first integer from the head of the
  238.         list is removed and returned.  When a character is written to a
  239.         stream, the integer representing the character code of the
  240.         character is appended to the end of the list.  When a function
  241.         indicates that it takes an input source as a parameter, this
  242.         parameter can either be an input file pointer or a stream.
  243.         Similarly, when a function indicates that it takes an output
  244.         sink as a parameter, this parameter can either be an output file
  245.         pointer or a stream.
  246.  
  247.  
  248.         XLISP                    THE EVALUATOR                    Page 9
  249.  
  250.         THE EVALUATOR
  251.  
  252.         The process of evaluation in XLISP:
  253.  
  254.         Integers, floats, strings, file pointers, subrs, fsubrs, objects
  255.         and arrays evaluate to themselves
  256.  
  257.         Symbols evaluate to the value associated with their current
  258.         binding
  259.  
  260.         Lists are evaluated by evaluating the first element of the list
  261.         and then taking one of the following actions:
  262.  
  263.             If it is a subr, the remaining list elements are evaluated
  264.             and the subr is called with these evaluated expressions as
  265.             arguments.
  266.  
  267.             If it is an fsubr, the fsubr is called using the remaining
  268.             list elements as arguments (unevaluated)
  269.  
  270.             If it is a list:
  271.  
  272.                 If the list is a function closure (a list whose car is a
  273.                 lambda expression and whose cdr is an environment list),
  274.                 the car of the list is used as the function to be
  275.                 applied and the cdr is used as the environment to be
  276.                 extended with the parameter bindings.
  277.  
  278.                 If the list is a lambda expression, the current
  279.                 environment is used for the function application.
  280.  
  281.                     In either of the above two cases, the remaining list
  282.                     elements are evaluated and the resulting expressions
  283.                     are bound to the formal arguments of the lambda
  284.                     expression.  The body of the function is executed
  285.                     within this new binding environment.
  286.  
  287.                 If it is a list and the car of the list is 'macro', the
  288.                 remaining list elements are bound to the formal
  289.                 arguments of the macro expression.  The body of the
  290.                 function is executed within this new binding
  291.                 environment.  The result of this evaluation is
  292.                 considered the macro expansion.  This result is then
  293.                 evaluated in place of the original expression.
  294.  
  295.                 If it is an object, the second list element is evaluated
  296.                 and used as a message selector.  The message formed by
  297.                 combining the selector with the values of the remaining
  298.                 list elements is sent to the object.
  299.  
  300.  
  301.         XLISP                 LEXICAL CONVENTIONS                Page 10
  302.         
  303.         LEXICAL CONVENTIONS
  304.  
  305.         The following conventions must be followed when entering XLISP
  306.         programs:
  307.  
  308.         Comments in XLISP code begin with a semi-colon character and
  309.         continue to the end of the line.
  310.  
  311.         Symbol names in XLISP can consist of any sequence of non-blank
  312.         printable characters except the following:
  313.  
  314.                 ( ) ' ` , " ;
  315.  
  316.         Uppercase and lowercase characters are not distinguished within
  317.         symbol names.  All lowercase characters are mapped to uppercase
  318.         on input.
  319.  
  320.         Integer literals consist of a sequence of digits optionally
  321.         beginning with a '+' or '-'.  The range of values an integer can
  322.         represent is limited by the size of a C 'long' on the machine on
  323.         which XLISP is running.
  324.  
  325.         Floating point literals consist of a sequence of digits
  326.         optionally beginning with a '+' or '-' and including an embedded
  327.         decimal point.  The range of values a floating point number can
  328.         represent is limited by the size of a C 'float' ('double' on
  329.         machines with 32 bit addresses) on the machine on which XLISP is
  330.         running.
  331.  
  332.         Literal strings are sequences of characters surrounded by double
  333.         quotes.  Within quoted strings the '' character is used to allow
  334.         non-printable characters to be included.  The codes recognized
  335.         are:
  336.  
  337.                 \\        means the character '\'
  338.                 \n       means newline
  339.                 \t       means tab
  340.                 \r       means return
  341.                 \f       means form feed
  342.                 \nnn     means the character whose octal code is nnn
  343.  
  344.  
  345.         XLISP defines several useful read macros:
  346.  
  347.                 '<expr>         == (quote <expr>)
  348.                 #'<expr>        == (function <expr>)
  349.                 #(<expr>...)    == an array of the specified expressions
  350.                 #x<hdigits>     == a hexadecimal number
  351.                 #\<char> == the ASCII code of the character
  352.                 `<expr>         == (backquote <expr>)
  353.                 ,<expr>         == (comma <expr>)
  354.                 ,@<expr>        == (comma-at <expr>)
  355.  
  356.  
  357.         XLISP                      READTABLES                    Page 11
  358.  
  359.         READTABLES
  360.  
  361.         The behaviour of the reader is controlled by a data structure
  362.         called a "readtable".  The reader uses the symbol *READTABLE* to
  363.         locate the current readtable.  This table controls the
  364.         interpretation of input characters.  It is an array with 128
  365.         entries, one for each of the ASCII character codes.  Each entry
  366.         contains one of the following things:
  367.  
  368.                 NIL             Indicating an invalid character
  369.                 :CONSTITUENT    Indicating a symbol constituent
  370.                 :WHITE-SPACE    Indicating a whitespace character
  371.                 (:TMACRO . fun) Terminating readmacro
  372.                 (:NMACRO . fun) Non-terminating readmacro
  373.  
  374.         In the case of the last two forms, the "fun" component is a
  375.         function definition.  This can either be a pointer to a built-in
  376.         readmacro function or a lambda expression.  The function should
  377.         take two parameters.  The first is the input stream and the
  378.         second is the character that caused the invocation of the
  379.         readmacro.  The character is passed as an integer.  The
  380.         readmacro function should return NIL to indicate that the
  381.         character should be treated as white space or a value consed
  382.         with NIL to indicate that the readmacro should be treated as an
  383.         occurance of the specified value.  Of course, the readmacro code
  384.         is free to read additional characters from the input stream.
  385.  
  386.  
  387.         XLISP                       OBJECTS                      Page 12
  388.  
  389.         OBJECTS
  390.  
  391.         Definitions:
  392.  
  393.             o selector - a symbol used to select an appropriate method
  394.             o message - a selector and a list of actual arguments
  395.             o method - the code that implements a message
  396.  
  397.         Since XLISP was created to provide a simple basis for
  398.         experimenting with object-oriented programming, one of the
  399.         primitive data types included is 'object'.  In XLISP, an object
  400.         consists of a data structure containing a pointer to the
  401.         object's class as well as an array containing the values of the
  402.         object's instance variables.
  403.  
  404.         Officially, there is no way to see inside an object (look at the
  405.         values of its instance variables).  The only way to communicate
  406.         with an object is by sending it a message.  When the XLISP
  407.         evaluator evaluates a list the value of whose first element is
  408.         an object, it interprets the value of the second element of the
  409.         list (which must be a symbol) as the message selector.  The
  410.         evaluator determines the class of the receiving object and
  411.         attempts to find a method corresponding to the message selector
  412.         in the set of messages defined for that class.  If the message
  413.         is not found in the object's class and the class has a super-
  414.         class, the search continues by looking at the messages defined
  415.         for the super-class.  This process continues from one super-
  416.         class to the next until a method for the message is found.  If
  417.         no method is found, an error occurs.
  418.  
  419.         When a method is found, the evaluator binds the receiving object
  420.         to the symbol 'self', binds the class in which the method was
  421.         found to the symbol 'msgclass', and evaluates the method using
  422.         the remaining elements of the original list as arguments to the
  423.         method.  These arguments are always evaluated prior to being
  424.         bound to their corresponding formal arguments.  The result of
  425.         evaluating the method becomes the result of the expression.
  426.  
  427.  
  428.         XLISP                       OBJECTS                      Page 13
  429.  
  430.         THE 'Object' CLASS
  431.  
  432.         Classes:
  433.  
  434.         Object  THE TOP OF THE CLASS HEIRARCHY
  435.  
  436.             Messages:
  437.  
  438.                 :show  SHOW AN OBJECT'S INSTANCE VARIABLES
  439.                     returns     the object
  440.  
  441.                 :class  RETURN THE CLASS OF AN OBJECT
  442.                     returns     the class of the object
  443.  
  444.                 :isnew  THE DEFAULT OBJECT INITIALIZATION ROUTINE
  445.                     returns     the object
  446.  
  447.                 :sendsuper <sel> [<args>]...  SEND SUPERCLASS A MESSAGE
  448.                     <sel>       the message selector
  449.                     <args>      the message arguments
  450.                     returns     the result of sending the message
  451.  
  452.  
  453.         XLISP                       OBJECTS                      Page 14
  454.  
  455.         THE 'Class' CLASS
  456.  
  457.         Class   THE CLASS OF ALL OBJECT CLASSES (including itself)
  458.  
  459.             Messages:
  460.  
  461.                 :new  CREATE A NEW INSTANCE OF A CLASS
  462.                     returns     the new class object
  463.  
  464.                 :isnew <ivars> [<cvars>[<super>]]  INITIALIZE A NEW CLASS
  465.                     <ivars>     the list of instance variable symbols
  466.                     <cvars>     the list of class variable symbols
  467.                     <super>     the superclass (default is Object)
  468.                     returns     the new class object
  469.  
  470.                 :answer <msg> <fargs> <code>  ADD A MESSAGE TO A CLASS
  471.                     <msg>       the message symbol
  472.                     <fargs>     the formal argument list
  473.                                   this list is of the form:
  474.                                     ([<farg>]...
  475.                                      [&optional [<oarg>]...]
  476.                                      [&rest <rarg>]
  477.                                      [&aux [<aux>]...])
  478.                                   where
  479.                                     <farg>   a formal argument
  480.                                     <oarg>   an optional argument
  481.                                     <rarg>   bound to rest of the arguments
  482.                                     <aux>    a auxiliary variable
  483.                     <code>      a list of executable expressions
  484.                     returns     the object
  485.  
  486.         When a new instance of a class is created by sending the message
  487.         ':new' to an existing class, the message ':isnew' followed by
  488.         whatever parameters were passed to the ':new' message is sent to
  489.         the newly created object.
  490.  
  491.         When a new class is created by sending the ':new' message to the
  492.         object 'Class', an optional parameter may be specified
  493.         indicating the superclass of the new class.  If this parameter
  494.         is omitted, the new class will be a subclass of 'Object'.  A
  495.         class inherits all instance variables, class variables, and
  496.         methods from its super-class.
  497.  
  498.  
  499.         XLISP                       SYMBOLS                      Page 15
  500.  
  501.         SYMBOLS
  502.  
  503.             o self - the current object (within a message context)
  504.             o msgclass - the class in which the current method was found
  505.             o *obarray* - the object hash table
  506.             o *standard-input* - the standard input file
  507.             o *standard-output* - the standard output file
  508.             o *breakenable* - flag controlling entering break loop on errors
  509.             o *tracenable* - enable baktrace on errors
  510.             o *tracelimit* - number of levels of trace back information
  511.             o *evalhook* - user substitute for the evaluator function
  512.             o *applyhook* - (not yet implemented)
  513.             o *readtable* - the current readtable
  514.             o *unbound* - indicator for unbound symbols
  515.             o *gc-flag* - controls the printing of gc messages
  516.  
  517.  
  518.         XLISP                 EVALUATION FUNCTIONS               Page 16
  519.  
  520.         EVALUATION FUNCTIONS
  521.  
  522.         (eval <expr>)  EVALUATE AN XLISP EXPRESSION
  523.             <expr>      the expression to be evaluated
  524.             returns     the result of evaluating the expression
  525.  
  526.         (apply <fun> <args>)  APPLY A FUNCTION TO A LIST OF ARGUMENTS
  527.             <fun>       the function to apply (or function symbol)
  528.             <args>      the argument list
  529.             returns     the result of applying the function to the arguments
  530.  
  531.         (funcall <fun> [<arg>]...)  CALL A FUNCTION WITH ARGUMENTS
  532.             <fun>       the function to call (or function symbol)
  533.             <arg>       arguments to pass to the function
  534.             returns     the result of calling the function with the arguments
  535.  
  536.         (quote <expr>)  RETURN AN EXPRESSION UNEVALUATED
  537.             <expr>      the expression to be quoted (quoted)
  538.             returns     <expr> unevaluated
  539.  
  540.         (function <expr>)  QUOTE A FUNCTION
  541.             <expr>      the function to be quoted (quoted)
  542.             returns     a function closure
  543.  
  544.         (backquote <expr>)  FILL IN A TEMPLATE
  545.             <expr>      the template
  546.             returns     a copy of the template with comma and comma-at
  547.                         expressions expanded
  548.  
  549.         (lambda <args> [<expr>]...)  MAKE A FUNCTION CLOSURE
  550.             <args>      the argument list (quoted)
  551.             <expr>      expressions of the function body
  552.             returns     the function closure
  553.  
  554.  
  555.         XLISP                   SYMBOL FUNCTIONS                 Page 17
  556.  
  557.         SYMBOL FUNCTIONS
  558.  
  559.         (set <sym> <expr>)  SET THE VALUE OF A SYMBOL
  560.             <sym>       the symbol being set
  561.             <expr>      the new value
  562.             returns     the new value
  563.  
  564.         (setq [<sym> <expr>]...)  SET THE VALUE OF A SYMBOL
  565.             <sym>       the symbol being set (quoted)
  566.             <expr>      the new value
  567.             returns     the new value
  568.  
  569.         (setf [<place> <expr>]...)  SET THE VALUE OF A FIELD
  570.             <place>     the field specifier (quoted):
  571.                             <sym>                set value of a symbol
  572.                             (car <expr>)         set car of a list node
  573.                             (cdr <expr>)         set cdr of a list node
  574.                             (nth <n> <expr>)     set nth car of a list
  575.                             (aref <expr> <n>)    set nth element of an array
  576.                             (get <sym> <prop>)   set value of a property
  577.                             (symbol-value <sym>) set value of a symbol
  578.                             (symbol-plist <sym>) set property list of a symbol
  579.             <value>     the new value
  580.             returns     the new value
  581.  
  582.         (defun <sym> <fargs> [<expr>]...)  DEFINE A FUNCTION
  583.         (defmacro <sym> <fargs> [<expr>]...)  DEFINE A MACRO
  584.             <sym>       symbol being defined (quoted)
  585.             <fargs>     list of formal arguments (quoted)
  586.                           this list is of the form:
  587.                             ([<farg>]...
  588.                              [&optional [<oarg>]...]
  589.                              [&rest <rarg>]
  590.                              [&aux [<aux>]...])
  591.                           where
  592.                             <farg>      is a formal argument
  593.                             <oarg>      is an optional argument
  594.                             <rarg>      bound to the rest of the arguments
  595.                             <aux>       is an auxiliary variable
  596.             <expr>      expressions constituting the body of the
  597.                         function (quoted)
  598.             returns     the function symbol
  599.  
  600.         (gensym [<tag>])  GENERATE A SYMBOL
  601.             <tag>       string or number
  602.             returns     the new symbol
  603.  
  604.         (intern <pname>)  MAKE AN INTERNED SYMBOL
  605.             <pname>     the symbol's print name string
  606.             returns     the new symbol
  607.  
  608.         (make-symbol <pname>)  MAKE AN UNINTERNED SYMBOL
  609.             <pname>     the symbol's print name string
  610.             returns     the new symbol
  611.  
  612.  
  613.         XLISP                   SYMBOL FUNCTIONS                 Page 18
  614.  
  615.         (symbol-name <sym>)  GET THE PRINT NAME OF A SYMBOL
  616.             <sym>       the symbol
  617.             returns     the symbol's print name
  618.  
  619.         (symbol-value <sym>)  GET THE VALUE OF A SYMBOL
  620.             <sym>       the symbol
  621.             returns     the symbol's value
  622.  
  623.         (symbol-plist <sym>)  GET THE PROPERTY LIST OF A SYMBOL
  624.             <sym>       the symbol
  625.             returns     the symbol's property list
  626.  
  627.         (hash <sym> <n>)  COMPUTE THE HASH INDEX FOR A SYMBOL
  628.             <sym>       the symbol or string
  629.             <n>         the table size (integer)
  630.             returns     the hash index (integer)
  631.  
  632.  
  633.         XLISP               PROPERTY LIST FUNCTIONS              Page 19
  634.  
  635.         PROPERTY LIST FUNCTIONS
  636.  
  637.         (get <sym> <prop>)  GET THE VALUE OF A PROPERTY
  638.             <sym>       the symbol
  639.             <prop>      the property symbol
  640.             returns     the property value or nil
  641.  
  642.         (putprop <sym> <val> <prop>)  PUT A PROPERTY ONTO A PROPERTY LIST
  643.             <sym>       the symbol
  644.             <val>       the property value
  645.             <prop>      the property symbol
  646.             returns     the property value
  647.  
  648.         (remprop <sym> <prop>)  REMOVE A PROPERTY
  649.             <sym>       the symbol
  650.             <prop>      the property symbol
  651.             returns     nil
  652.  
  653.  
  654.         XLISP                   ARRAY FUNCTIONS                  Page 20
  655.  
  656.         ARRAY FUNCTIONS
  657.  
  658.         (aref <array> <n>)  GET THE NTH ELEMENT OF AN ARRAY
  659.             <array>     the array
  660.             <n>         the array index (integer)
  661.             returns     the value of the array element
  662.  
  663.         (make-array <size>)  MAKE A NEW ARRAY
  664.             <size>      the size of the new array (integer)
  665.             returns     the new array
  666.  
  667.  
  668.         XLISP                    LIST FUNCTIONS                  Page 21
  669.  
  670.         LIST FUNCTIONS
  671.  
  672.         (car <expr>)  RETURN THE CAR OF A LIST NODE
  673.             <expr>      the list node
  674.             returns     the car of the list node
  675.  
  676.         (cdr <expr>)  RETURN THE CDR OF A LIST NODE
  677.             <expr>      the list node
  678.             returns     the cdr of the list node
  679.  
  680.         (cxxr <expr>)  ALL CxxR COMBINATIONS
  681.         (cxxxr <expr>)  ALL CxxxR COMBINATIONS
  682.         (cxxxxr <expr>)  ALL CxxxxR COMBINATIONS
  683.  
  684.         (cons <expr1> <expr2>)  CONSTRUCT A NEW LIST NODE
  685.             <expr1>     the car of the new list node
  686.             <expr2>     the cdr of the new list node
  687.             returns     the new list node
  688.  
  689.         (list [<expr>]...)  CREATE A LIST OF VALUES
  690.             <expr>      expressions to be combined into a list
  691.             returns     the new list
  692.  
  693.         (append [<expr>]...)  APPEND LISTS
  694.             <expr>      lists whose elements are to be appended
  695.             returns     the new list
  696.  
  697.         (reverse <expr>)  REVERSE A LIST
  698.             <expr>      the list to reverse
  699.             returns     a new list in the reverse order
  700.  
  701.         (last <list>)  RETURN THE LAST LIST NODE OF A LIST
  702.             <list>      the list
  703.             returns     the last list node in the list
  704.  
  705.         (member <expr> <list> [<key> <test>])  FIND AN EXPRESSION IN A LIST
  706.             <expr>      the expression to find
  707.             <list>      the list to search
  708.             <key>       the keyword :test or :test-not
  709.             <test>      the test function (defaults to eql)
  710.             returns     the remainder of the list starting with the expression
  711.  
  712.         (assoc <expr> <alist> [<key> <test>])  FIND AN EXPRESSION IN AN A-LIST
  713.             <expr>      the expression to find
  714.             <alist>     the association list
  715.             <key>       the keyword :test or :test-not
  716.             <test>      the test function (defaults to eql)
  717.             returns     the alist entry or nil
  718.  
  719.  
  720.         XLISP                    LIST FUNCTIONS                  Page 22
  721.         
  722.         (remove <expr> <list> [<key> <test>])  REMOVE AN EXPRESSION
  723.             <expr>      the expression to delete
  724.             <list>      the list
  725.             <key>       the keyword :test or :test-not
  726.             <test>      the test function (defaults to eql)
  727.             returns     the list with the matching expressions deleted
  728.  
  729.         (length <expr>)  FIND THE LENGTH OF A LIST OR STRING
  730.             <expr>      the list or string
  731.             returns     the length of the list or string
  732.  
  733.         (nth <n> <list>)  RETURN THE NTH ELEMENT OF A LIST
  734.             <n>         the number of the element to return (zero origin)
  735.             <list>      the list
  736.             returns     the nth element or nil if the list isn't that long
  737.  
  738.         (nthcdr <n> <list>)  RETURN THE NTH CDR OF A LIST
  739.             <n>         the number of the element to return (zero origin)
  740.             <list>      the list
  741.             returns     the nth cdr or nil if the list isn't that long
  742.  
  743.         (mapc <fcn> <list1> [<list>]...)  APPLY FUNCTION TO SUCCESSIVE CARS
  744.             <fcn>       the function or function name
  745.             <listn>     a list for each argument of the function
  746.             returns     the first list of arguments
  747.  
  748.         (mapcar <fcn> <list1> [<list>]...)  APPLY FUNCTION TO SUCCESSIVE CARS
  749.             <fcn>       the function or function name
  750.             <listn>     a list for each argument of the function
  751.             returns     a list of the values returned
  752.  
  753.         (mapl <fcn> <list1> [<list>]...)  APPLY FUNCTION TO SUCCESSIVE CDRS
  754.             <fcn>       the function or function name
  755.             <listn>     a list for each argument of the function
  756.             returns     the first list of arguments
  757.  
  758.         (maplist <fcn> <list1> [<list>]...) APPLY FUNCTION TO SUCCESSIVE CDRS
  759.             <fcn>       the function or function name
  760.             <listn>     a list for each argument of the function
  761.             returns     a list of the values returned
  762.  
  763.  
  764.         XLISP                    LIST FUNCTIONS                  Page 23
  765.  
  766.         (subst <to> <from> <expr> [<key> <test>])  SUBSTITUTE EXPRESSIONS
  767.             <to>        the new expression
  768.             <from>      the old expression
  769.             <expr>      the expression in which to do the substitutions
  770.             <key>       the keyword :test or :test-not
  771.             <test>      the test function (defaults to eql)
  772.             returns     the expression with substitutions
  773.  
  774.         (sublis <alist> <expr> [<key> <test>])  SUBSTITUTE WITH AN A-LIST
  775.             <alist>     the association list
  776.             <expr>      the expression in which to do the substitutions
  777.             <key>       the keyword :test or :test-not
  778.             <test>      the test function (defaults to eql)
  779.             returns     the expression with substitutions
  780.  
  781.  
  782.         XLISP              DESTRUCTIVE LIST FUNCTIONS            Page 24
  783.  
  784.         DESTRUCTIVE LIST FUNCTIONS
  785.  
  786.         (rplaca <list> <expr>)  REPLACE THE CAR OF A LIST NODE
  787.             <list>      the list node
  788.             <expr>      the new value for the car of the list node
  789.             returns     the list node after updating the car
  790.  
  791.         (rplacd <list> <expr>)  REPLACE THE CDR OF A LIST NODE
  792.             <list>      the list node
  793.             <expr>      the new value for the cdr of the list node
  794.             returns     the list node after updating the cdr
  795.  
  796.         (nconc [<list>]...)  DESTRUCTIVELY CONCATENATE LISTS
  797.             <list>      lists to concatenate
  798.             returns     the result of concatenating the lists
  799.  
  800.         (delete <expr> <list> [<key> <test>])  DELETE AN EXPRESSION FROM A LIST
  801.             <expr>      the expression to delete
  802.             <list>      the list
  803.             <key>       the keyword :test or :test-not
  804.             <test>      the test function (defaults to eql)
  805.             returns     the list with the matching expressions deleted
  806.  
  807.  
  808.         XLISP                 PREDICATE FUNCTIONS                Page 25
  809.  
  810.         PREDICATE FUNCTIONS
  811.  
  812.         (atom <expr>)  IS THIS AN ATOM?
  813.             <expr>      the expression to check
  814.             returns     t if the value is an atom, nil otherwise
  815.  
  816.         (symbolp <expr>)  IS THIS A SYMBOL?
  817.             <expr>      the expression to check
  818.             returns     t if the expression is a symbol, nil otherwise
  819.  
  820.         (numberp <expr>)  IS THIS A NUMBER?
  821.             <expr>      the expression to check
  822.             returns     t if the expression is a number, nil otherwise
  823.  
  824.         (null <expr>)  IS THIS AN EMPTY LIST?
  825.             <expr>      the list to check
  826.             returns     t if the list is empty, nil otherwise
  827.  
  828.         (not <expr>)  IS THIS FALSE?
  829.             <expr>      the expression to check
  830.             return      t if the expression is nil, nil otherwise
  831.  
  832.         (listp <expr>)  IS THIS A LIST?
  833.             <expr>      the expression to check
  834.             returns     t if the value is a list node or nil, nil otherwise
  835.  
  836.         (consp <expr>)  IS THIS A NON-EMPTY LIST?
  837.             <expr>      the expression to check
  838.             returns     t if the value is a list node, nil otherwise
  839.  
  840.         (boundp <sym>)  IS THIS A BOUND SYMBOL?
  841.             <sym>       the symbol
  842.             returns     t if a value is bound to the symbol, nil otherwise
  843.  
  844.  
  845.         XLISP                 PREDICATE FUNCTIONS                Page 26
  846.  
  847.         (minusp <expr>)  IS THIS NUMBER NEGATIVE?
  848.             <expr>      the number to test
  849.             returns     t if the number is negative, nil otherwise
  850.  
  851.         (zerop <expr>)  IS THIS NUMBER ZERO?
  852.             <expr>      the number to test
  853.             returns     t if the number is zero, nil otherwise
  854.  
  855.         (plusp <expr>)  IS THIS NUMBER POSITIVE?
  856.             <expr>      the number to test
  857.             returns     t if the number is positive, nil otherwise
  858.  
  859.         (evenp <expr>)  IS THIS NUMBER EVEN?
  860.             <expr>      the number to test
  861.             returns     t if the number is even, nil otherwise
  862.  
  863.         (oddp <expr>)  IS THIS NUMBER ODD?
  864.             <expr>      the number to test
  865.             returns     t if the number is odd, nil otherwise
  866.  
  867.         (eq <expr1> <expr2>)  ARE THE EXPRESSIONS IDENTICAL?
  868.             <expr1>     the first expression
  869.             <expr2>     the second expression
  870.             returns     t if they are equal, nil otherwise
  871.  
  872.         (eql <expr1> <expr2>)  ARE THE EXPRESSIONS IDENTICAL?
  873.                                 (WORKS WITH NUMBERS AND STRINGS)
  874.             <expr1>     the first expression
  875.             <expr2>     the second expression
  876.             returns     t if they are equal, nil otherwise
  877.  
  878.         (equal <expr1> <expr2>)  ARE THE EXPRESSIONS EQUAL?
  879.             <expr1>     the first expression
  880.             <expr2>     the second expression
  881.             returns     t if they are equal, nil otherwise
  882.  
  883.  
  884.         XLISP                  CONTROL CONSTRUCTS                Page 27
  885.  
  886.         CONTROL CONSTRUCTS
  887.  
  888.         (cond [<pair>]...)  EVALUATE CONDITIONALLY
  889.             <pair>      pair consisting of:
  890.                             (<pred> [<expr>]...)
  891.                           where
  892.                             <pred>      is a predicate expression
  893.                             <expr>      evaluated if the predicate
  894.                                         is not nil
  895.             returns     the value of the first expression whose predicate
  896.                         is not nil
  897.  
  898.         (and [<expr>]...)  THE LOGICAL AND OF A LIST OF EXPRESSIONS
  899.             <expr>      the expressions to be ANDed
  900.             returns     nil if any expression evaluates to nil,
  901.                         otherwise the value of the last expression
  902.                         (evaluation of expressions stops after the first
  903.                          expression that evaluates to nil)
  904.  
  905.         (or [<expr>]...)  THE LOGICAL OR OF A LIST OF EXPRESSIONS
  906.             <expr>      the expressions to be ORed
  907.             returns     nil if all expressions evaluate to nil,
  908.                         otherwise the value of the first non-nil expression
  909.                         (evaluation of expressions stops after the first
  910.                          expression that does not evaluate to nil)
  911.  
  912.         (if <texpr> <expr1> [<expr2>])  EXECUTE EXPRESSIONS CONDITIONALLY
  913.             <texpr>     the test expression
  914.             <expr1>     the expression to be evaluated if texpr is non-nil
  915.             <expr2>     the expression to be evaluated if texpr is nil
  916.             returns     the value of the selected expression
  917.  
  918.         (case <expr> [<case>]...)  SELECT BY CASE
  919.             <expr>      the selection expression
  920.             <case>      pair consisting of:
  921.                             (<value> [<expr>]...)
  922.                           where:
  923.                             <value>     is a single expression or a list of
  924.                                         expressions (unevaluated)
  925.                             <expr>      are expressions to execute if the
  926.                                         case matches
  927.             returns     the value of the last expression of the matching case
  928.  
  929.         (let ([<binding>]...) [<expr>]...)  CREATE LOCAL BINDINGS
  930.         (let* ([<binding>]...) [<expr>]...)  LET WITH SEQUENTIAL BINDING
  931.             <binding>   the variable bindings each of which is either:
  932.                         1)  a symbol (which is initialized to nil)
  933.                         2)  a list whose car is a symbol and whose cadr
  934.                                 is an initialization expression
  935.             <expr>      the expressions to be evaluated
  936.             returns     the value of the last expression
  937.  
  938.         (catch <sym> [<expr>]...)  EVALUATE EXPRESSIONS AND CATCH THROWS
  939.             <sym>       the catch tag
  940.  
  941.  
  942.         XLISP                  CONTROL CONSTRUCTS                Page 28
  943.  
  944.             <expr>      expressions to evaluate
  945.             returns     the value of the last expression the throw expression
  946.  
  947.         (throw <sym> [<expr>])  THROW TO A CATCH
  948.             <sym>       the catch tag
  949.             <expr>      the value for the catch to return (defaults to nil)
  950.             returns     never returns
  951.  
  952.  
  953.         XLISP                  LOOPING CONSTRUCTS                Page 29
  954.  
  955.         LOOPING CONSTRUCTS
  956.  
  957.         (do ([<binding>]...) (<texpr> [<rexpr>]...) [<expr>]...)
  958.         (do* ([<binding>]...) (<texpr> [<rexpr>]...) [<expr>]...)
  959.             <binding>   the variable bindings each of which is either:
  960.                         1)  a symbol (which is initialized to nil)
  961.                         2)  a list of the form: (<sym> <init> [<step>])
  962.                             where:
  963.                                 <sym>  is the symbol to bind
  964.                                 <init> is the initial value of the symbol
  965.                                 <step> is a step expression
  966.             <texpr>     the termination test expression
  967.             <rexpr>     result expressions (the default is nil)
  968.             <expr>      the body of the loop (treated like an implicit prog)
  969.             returns     the value of the last result expression
  970.  
  971.         (dolist (<sym> <expr> [<rexpr>]) [<expr>]...)  LOOP THROUGH A LIST
  972.             <sym>       the symbol to bind to each list element
  973.             <expr>      the list expression
  974.             <rexpr>     the result expression (the default is nil)
  975.             <expr>      the body of the loop (treated like an implicit prog)
  976.  
  977.         (dotimes (<sym> <expr> [<rexpr>]) [<expr>]...)  LOOP FROM ZERO TO N-1
  978.             <sym>       the symbol to bind to each value from 0 to n-1
  979.             <expr>      the number of times to loop
  980.             <rexpr>     the result expression (the default is nil)
  981.             <expr>      the body of the loop (treated like an implicit prog)
  982.  
  983.  
  984.         XLISP                 THE PROGRAM FEATURE                Page 30
  985.  
  986.         THE PROGRAM FEATURE
  987.  
  988.         (prog ([<binding>]...) [<expr>]...)  THE PROGRAM FEATURE
  989.         (prog* ([<binding>]...) [<expr>]...)  PROG WITH SEQUENTIAL BINDING
  990.             <binding>   the variable bindings each of which is either:
  991.                         1)  a symbol (which is initialized to nil)
  992.                         2)  a list whose car is a symbol and whose cadr
  993.                                 is an initialization expression
  994.             <expr>      expressions to evaluate or tags (symbols)
  995.             returns     nil or the argument passed to the return function
  996.  
  997.         (go <sym>)  GO TO A TAG WITHIN A PROG CONSTRUCT
  998.             <sym>       the tag (quoted)
  999.             returns     never returns
  1000.  
  1001.         (return [<expr>])  CAUSE A PROG CONSTRUCT TO RETURN A VALUE
  1002.             <expr>      the value (defaults to nil)
  1003.             returns     never returns
  1004.  
  1005.         (prog1 <expr1> [<expr>]...)  EXECUTE EXPRESSIONS SEQUENTIALLY
  1006.             <expr1>     the first expression to evaluate
  1007.             <expr>      the remaining expressions to evaluate
  1008.             returns     the value of the first expression
  1009.  
  1010.         (prog2 <expr1> <expr2> [<expr>]...)  EXECUTE EXPRESSIONS SEQUENTIALLY
  1011.             <expr1>     the first expression to evaluate
  1012.             <expr2>     the second expression to evaluate
  1013.             <expr>      the remaining expressions to evaluate
  1014.             returns     the value of the second expression
  1015.  
  1016.         (progn [<expr>]...)  EXECUTE EXPRESSIONS SEQUENTIALLY
  1017.             <expr>      the expressions to evaluate
  1018.             returns     the value of the last expression (or nil)
  1019.  
  1020.  
  1021.         XLISP             DEBUGGING AND ERROR HANDLING           Page 31
  1022.  
  1023.         DEBUGGING AND ERROR HANDLING
  1024.  
  1025.         (error <emsg> [<arg>])  SIGNAL A NON-CORRECTABLE ERROR
  1026.             <emsg>      the error message string
  1027.             <arg>       the argument expression (printed after the message)
  1028.             returns     never returns
  1029.  
  1030.         (cerror <cmsg> <emsg> [<arg>])  SIGNAL A CORRECTABLE ERROR
  1031.             <cmsg>      the continue message string
  1032.             <emsg>      the error message string
  1033.             <arg>       the argument expression (printed after the message)
  1034.             returns     nil when continued from the break loop
  1035.  
  1036.         (break [<bmsg> [<arg>]])  ENTER A BREAK LOOP
  1037.             <bmsg>      the break message string (defaults to "**BREAK**")
  1038.             <arg>       the argument expression (printed after the message)
  1039.             returns     nil when continued from the break loop
  1040.  
  1041.         (clean-up)  CLEAN-UP AFTER AN ERROR
  1042.             returns     never returns
  1043.  
  1044.         (top-level)  CLEAN-UP AFTER AN ERROR AND RETURN TO THE TOP LEVEL
  1045.             returns     never returns
  1046.  
  1047.         (continue)  CONTINUE FROM A CORRECTABLE ERROR
  1048.             returns     never returns
  1049.  
  1050.         (errset <expr> [<pflag>])  TRAP ERRORS
  1051.             <expr>      the expression to execute
  1052.             <pflag>     flag to control printing of the error message
  1053.             returns     the value of the last expression consed with nil
  1054.                         or nil on error
  1055.  
  1056.         (baktrace [<n>])  PRINT N LEVELS OF TRACE BACK INFORMATION
  1057.             <n>         the number of levels (defaults to all levels)
  1058.             returns     nil
  1059.  
  1060.         (evalhook <expr> <ehook> <ahook> [<env>])  EVALUATE WITH HOOKS
  1061.             <expr>      the expression to evaluate
  1062.             <ehook>     the value for *evalhook*
  1063.             <ahook>     the value for *applyhook*
  1064.             <env>       the environment (default is nil)
  1065.             returns     the result of evaluating the expression
  1066.  
  1067.  
  1068.         XLISP                 ARITHMETIC FUNCTIONS               Page 32
  1069.  
  1070.         ARITHMETIC FUNCTIONS
  1071.  
  1072.         (truncate <expr>)  TRUNCATES A FLOATING POINT NUMBER TO AN INTEGER
  1073.             <expr>      the number
  1074.             returns     the result of truncating the number
  1075.  
  1076.         (float <expr>)  CONVERTS AN INTEGER TO A FLOATING POINT NUMBER
  1077.             <expr>      the number
  1078.             returns     the result of floating the integer
  1079.  
  1080.         (+ <expr>...)  ADD A LIST OF NUMBERS
  1081.             <expr>      the numbers
  1082.             returns     the result of the addition
  1083.  
  1084.         (- <expr>...)  SUBTRACT A LIST OF NUMBERS OR NEGATE A SINGLE NUMBER
  1085.             <expr>      the numbers
  1086.             returns     the result of the subtraction
  1087.  
  1088.         (* <expr>...)  MULTIPLY A LIST OF NUMBERS
  1089.             <expr>      the numbers
  1090.             returns     the result of the multiplication
  1091.  
  1092.         (/ <expr>...)  DIVIDE A LIST OF NUMBERS
  1093.             <expr>      the numbers
  1094.             returns     the result of the division
  1095.  
  1096.         (1+ <expr>)  ADD ONE TO A NUMBER
  1097.             <expr>      the number
  1098.             returns     the number plus one
  1099.  
  1100.         (1- <expr>)  SUBTRACT ONE FROM A NUMBER
  1101.             <expr>      the number
  1102.             returns     the number minus one
  1103.  
  1104.         (rem <expr>...)  REMAINDER OF A LIST OF NUMBERS
  1105.             <expr>      the numbers
  1106.             returns     the result of the remainder operation
  1107.  
  1108.         (min <expr>...)  THE SMALLEST OF A LIST OF NUMBERS
  1109.             <expr>      the expressions to be checked
  1110.             returns     the smallest number in the list
  1111.  
  1112.         (max <expr>...)  THE LARGEST OF A LIST OF NUMBERS
  1113.             <expr>      the expressions to be checked
  1114.             returns     the largest number in the list
  1115.  
  1116.         (abs <expr>)  THE ABSOLUTE VALUE OF A NUMBER
  1117.             <expr>      the number
  1118.             returns     the absolute value of the number
  1119.  
  1120.         (random <n>)  COMPUTE A RANDOM NUMBER BETWEEN 1 and N-1
  1121.             <n>         the upper bound (integer)
  1122.             returns     a random number
  1123.  
  1124.  
  1125.         XLISP                 ARITHMETIC FUNCTIONS               Page 33
  1126.  
  1127.         (sin <expr>)  COMPUTE THE SINE OF A NUMBER
  1128.             <expr>      the floating point number
  1129.             returns     the sine of the number
  1130.  
  1131.         (cos <expr>)  COMPUTE THE COSINE OF A NUMBER
  1132.             <expr>      the floating point number
  1133.             returns     the cosine of the number
  1134.  
  1135.         (tan <expr>)  COMPUTE THE TANGENT OF A NUMBER
  1136.             <expr>      the floating point number
  1137.             returns     the tangent of the number
  1138.  
  1139.         (expt <x-expr> <y-expr>)  COMPUTE X TO THE Y POWER
  1140.             <x-expr>    the floating point number
  1141.             <y-expr>    the floating point exponent
  1142.             returns     x to the y power
  1143.  
  1144.         (exp <x-expr>)  COMPUTE E TO THE X POWER
  1145.             <x-expr>    the floating point number
  1146.             returns     e to the x power
  1147.  
  1148.         (sqrt <expr>)  COMPUTE THE SQUARE ROOT OF A NUMBER
  1149.             <expr>      the floating point number
  1150.             returns     the square root of the number
  1151.  
  1152.  
  1153.         XLISP              BITWISE LOGICAL FUNCTIONS             Page 34
  1154.  
  1155.         BITWISE LOGICAL FUNCTIONS
  1156.  
  1157.         (logand <expr>...)  THE BITWISE AND OF A LIST OF NUMBERS
  1158.             <expr>      the numbers
  1159.             returns     the result of the and operation
  1160.  
  1161.         (logior <expr>...)  THE BITWISE INCLUSIVE OR OF A LIST OF NUMBERS
  1162.             <expr>      the numbers
  1163.             returns     the result of the inclusive or operation
  1164.  
  1165.         (logxor <expr>...)  THE BITWISE EXCLUSIVE OR OF A LIST OF NUMBERS
  1166.             <expr>      the numbers
  1167.             returns     the result of the exclusive or operation
  1168.  
  1169.         (lognot <expr>)  THE BITWISE NOT OF A NUMBER
  1170.             <expr>      the number
  1171.             returns     the bitwise inversion of number
  1172.  
  1173.  
  1174.         XLISP                 RELATIONAL FUNCTIONS               Page 35
  1175.  
  1176.         RELATIONAL FUNCTIONS
  1177.  
  1178.         The relational functions can be used to compare integers,
  1179.         floating point numbers or strings.
  1180.  
  1181.         (< <e1> <e2>)  TEST FOR LESS THAN
  1182.             <e1>        the left operand of the comparison
  1183.             <e2>        the right operand of the comparison
  1184.             returns     the result of comparing <e1> with <e2>
  1185.  
  1186.         (<= <e1> <e2>)  TEST FOR LESS THAN OR EQUAL TO
  1187.             <e1>        the left operand of the comparison
  1188.             <e2>        the right operand of the comparison
  1189.             returns     the result of comparing <e1> with <e2>
  1190.  
  1191.         (= <e1> <e2>)  TEST FOR EQUAL TO
  1192.             <e1>        the left operand of the comparison
  1193.             <e2>        the right operand of the comparison
  1194.             returns     the result of comparing <e1> with <e2>
  1195.  
  1196.         (/= <e1> <e2>)  TEST FOR NOT EQUAL TO
  1197.             <e1>        the left operand of the comparison
  1198.             <e2>        the right operand of the comparison
  1199.             returns     the result of comparing <e1> with <e2>
  1200.  
  1201.         (>= <e1> <e2>)  TEST FOR GREATER THAN OR EQUAL TO
  1202.             <e1>        the left operand of the comparison
  1203.             <e2>        the right operand of the comparison
  1204.             returns     the result of comparing <e1> with <e2>
  1205.  
  1206.         (> <e1> <e2>)  TEST FOR GREATER THAN
  1207.             <e1>        the left operand of the comparison
  1208.             <e2>        the right operand of the comparison
  1209.             returns     the result of comparing <e1> with <e2>
  1210.  
  1211.  
  1212.  
  1213.         XLISP                   STRING FUNCTIONS                 Page 36
  1214.  
  1215.         STRING FUNCTIONS
  1216.  
  1217.         (char <string> <index>)  EXTRACT A CHARACTER FROM A STRING
  1218.             <string>    the string
  1219.             <index>     the string index (zero relative)
  1220.             returns     the ascii code of the character
  1221.  
  1222.         (string <expr>)  MAKE A STRING FROM AN INTEGER ASCII VALUE
  1223.             <expr>      the integer
  1224.             returns     a one character string
  1225.  
  1226.         (strcat [<expr>]...)  CONCATENATE STRINGS
  1227.             <expr>      the strings to concatenate
  1228.             returns     the result of concatenating the strings
  1229.  
  1230.         (substr <expr> <sexpr> [<lexpr>]) EXTRACT A SUBSTRING
  1231.             <expr>      the string
  1232.             <sexpr>     the starting position
  1233.             <lexpr>     the length (default is rest of string)
  1234.             returns     substring starting at <sexpr> for <lexpr>
  1235.  
  1236.  
  1237.  
  1238.         XLISP                INPUT/OUTPUT FUNCTIONS              Page 37
  1239.  
  1240.         INPUT/OUTPUT FUNCTIONS
  1241.  
  1242.         (read [<source> [<eof> [<rflag>]]])  READ AN XLISP EXPRESSION
  1243.             <source>    the input source (default is standard input)
  1244.             <eof>       the value to return on end of file (default is nil)
  1245.             <rflag>     recursive read flag (default is nil)
  1246.             returns     the expression read
  1247.  
  1248.         (print <expr> [<sink>])  PRINT A LIST OF VALUES ON A NEW LINE
  1249.             <expr>      the expressions to be printed
  1250.             <sink>      the output sink (default is standard output)
  1251.             returns     the expression
  1252.  
  1253.         (prin1 <expr> [<sink>])  PRINT A LIST OF VALUES
  1254.             <expr>      the expressions to be printed
  1255.             <sink>      the output sink (default is standard output)
  1256.             returns     the expression
  1257.  
  1258.         (princ <expr> [<sink>])  PRINT A LIST OF VALUES WITHOUT QUOTING
  1259.             <expr>      the expressions to be printed
  1260.             <sink>      the output sink (default is standard output)
  1261.             returns     the expression
  1262.  
  1263.         (terpri [<sink>])  TERMINATE THE CURRENT PRINT LINE
  1264.             <sink>      the output sink (default is standard output)
  1265.             returns     nil
  1266.  
  1267.         (flatsize <expr>)  LENGTH OF PRINTED REPRESENTATION USING PRIN1
  1268.             <expr>      the expression
  1269.             returns     the length
  1270.  
  1271.         (flatc <expr>)  LENGTH OF PRINTED REPRESENTATION USING PRINC
  1272.             <expr>      the expression
  1273.             returns     the length
  1274.  
  1275.  
  1276.         XLISP                  FILE I/O FUNCTIONS                Page 38
  1277.  
  1278.         FILE I/O FUNCTIONS
  1279.  
  1280.         (openi <fname>)  OPEN AN INPUT FILE
  1281.             <fname>     the file name string or symbol
  1282.             returns     a file pointer
  1283.  
  1284.         (openo <fname>)  OPEN AN OUTPUT FILE
  1285.             <fname>     the file name string or symbol
  1286.             returns     a file pointer
  1287.  
  1288.         (close <fp>)  CLOSE A FILE
  1289.             <fp>        the file pointer
  1290.             returns     nil
  1291.  
  1292.         (read-char [<source>])  READ A CHARACTER FROM A FILE OR STREAM
  1293.             <source>    the input source (default is standard input)
  1294.             returns     the character (integer)
  1295.  
  1296.         (peek-char [<flag> [<source>]])  PEEK AT THE NEXT CHARACTER
  1297.             <flag>      flag for skipping white space (default is nil)
  1298.             <source>    the input source (default is standard input)
  1299.             returns     the character (integer)
  1300.  
  1301.         (write-char <ch> [<sink>])  WRITE A CHARACTER TO A FILE OR STREAM
  1302.             <ch>        the character to put (integer)
  1303.             <sink>      the output sink (default is standard output)
  1304.             returns     the character (integer)
  1305.  
  1306.         (read-line [<source>])  READ A LINE FROM A FILE OR STREAM
  1307.             <source>    the input source (default is standard input)
  1308.             returns     the input string
  1309.  
  1310.  
  1311.         XLISP                   SYSTEM FUNCTIONS                 Page 39
  1312.  
  1313.         SYSTEM FUNCTIONS
  1314.  
  1315.         (load <fname> [<vflag> [<pflag>]])  LOAD AN XLISP SOURCE FILE
  1316.             <fname>     the filename string or symbol
  1317.             <vflag>     the verbose flag (default is t)
  1318.             <pflag>     the print flag (default is nil)
  1319.             returns     the filename
  1320.  
  1321.         (transcript [<fname>])  CREATE A FILE WITH A TRANSCRIPT OF A SESSION
  1322.             <fname>     file name string or symbol
  1323.                         (if missing, close current transcript)
  1324.             returns     t if the transcript is opened, nil if it is closed
  1325.  
  1326.         (gc)  FORCE GARBAGE COLLECTION
  1327.             returns     nil
  1328.  
  1329.         (expand <num>)  EXPAND MEMORY BY ADDING SEGMENTS
  1330.             <num>       the number of segments to add
  1331.             returns     the number of segments added
  1332.  
  1333.         (alloc <num>)  CHANGE NUMBER OF NODES TO ALLOCATE IN EACH SEGMENT
  1334.             <num>       the number of nodes to allocate
  1335.             returns     the old number of nodes to allocate
  1336.  
  1337.         (mem)  SHOW MEMORY ALLOCATION STATISTICS
  1338.             returns     nil
  1339.  
  1340.         (type-of <expr>)  RETURNS THE TYPE OF THE EXPRESSION
  1341.             <expr>      the expression to return the type of
  1342.             returns     nil if the value is nil otherwise one of the symbols:
  1343.                           :SYMBOL for symbols
  1344.                           :OBJECT for objects
  1345.                           :CONS   for conses
  1346.                           :SUBR   for built-ins with evaluated arguments
  1347.                           :FSUBR  for built-ins with unevaluated arguments
  1348.                           :STRING for strings
  1349.                           :FIXNUM for integers
  1350.                           :FLONUM for floating point numbers
  1351.                           :FILE   for file pointers
  1352.                           :ARRAY  for arrays
  1353.  
  1354.         (peek <addrs>)  PEEK AT A LOCATION IN MEMORY
  1355.             <addrs>     the address to peek at (integer)
  1356.             returns     the value at the specified address (integer)
  1357.  
  1358.         (poke <addrs> <value>)  POKE A VALUE INTO MEMORY
  1359.             <addrs>     the address to poke (integer)
  1360.             <value>     the value to poke into the address (integer)
  1361.             returns     the value
  1362.  
  1363.         (address-of <expr>)  GET THE ADDRESS OF AN XLISP NODE
  1364.             <expr>      the node
  1365.             returns     the address of the node (integer)
  1366.  
  1367.  
  1368.         XLISP                   SYSTEM FUNCTIONS                 Page 40
  1369.  
  1370.         (exit)  EXIT XLISP
  1371.             returns     never returns
  1372.  
  1373.  
  1374.         XLISP                       EXAMPLES                     Page 41
  1375.  
  1376.         FILE I/O FUNCTIONS
  1377.  
  1378.         Input from a File
  1379.  
  1380.         XLISP provides two functions for opening files.  To open a file
  1381.         for input, use the OPENI function.  To open a file for output,
  1382.         use the OPENO function.  Both of these functions take a single
  1383.         argument which is the name of the file to be opened.  This name
  1384.         can be in the form of a string or a symbol.  Both open functions
  1385.         return an object of type :FILE as their result if they succeed
  1386.         in opening the specified file.  They return the value NIL if
  1387.         they are not successful.  In order to manipulate the file, it is
  1388.         necessary to save the value returned by the open function.  This
  1389.         is usually done by assigning it to a variable with the SETQ
  1390.         special form or by binding it using LET or LET*.  Here is an
  1391.         example:
  1392.  
  1393.             (setq fp (openi "init.lsp"))
  1394.  
  1395.         Evaluating this expression will result in the file "init.lsp"
  1396.         being opened.  The file object that will be returned by the
  1397.         OPENI function will be assigned to the variable "fp".
  1398.  
  1399.         It is now possible to use the file for input.  To read an
  1400.         expression from the file, just supply the value of the "fp"
  1401.         variable as the optional "stream" argument to READ.
  1402.  
  1403.             (read fp)
  1404.  
  1405.         Evaluating this expression will result in reading the first
  1406.         expression from the file "init.lsp".  The expression will be
  1407.         returned as the result of the READ function.  More expressions
  1408.         can be read from the file using further calls to the READ
  1409.         function.  When there are no more expressions to read, the READ
  1410.         function will return NIL (or whatever value was supplied as the
  1411.         second argument to READ).
  1412.  
  1413.         Once you are done reading from the file, you should close it.
  1414.         To close the file, use the following expression:
  1415.  
  1416.             (close fp)
  1417.  
  1418.         Evaluating this expression will cause the file to be closed.
  1419.  
  1420.  
  1421.         XLISP                       EXAMPLES                     Page 42
  1422.  
  1423.         Output to a File
  1424.  
  1425.         Writing to a file is pretty much the same as reading from one.
  1426.         You need to open the file first.  This time you should use the
  1427.         OPENO function to indicate that you will do output to the file.
  1428.         For example:
  1429.  
  1430.             (setq fp (openo "test.dat"))
  1431.  
  1432.         Evaluating this expression will open the file "test.dat" for
  1433.         output.  If the file already exists, its current contents will
  1434.         be discarded.  If it doesn't already exist, it will be created.
  1435.         In any case, a :FILE object will be returned by the OPENO
  1436.         function.  This file object will be assigned to the "fp"
  1437.         variable.
  1438.  
  1439.         It is now possible to write to this file by supplying the value
  1440.         of the "fp" variable as the optional "stream" parameter in the
  1441.         PRINT function.
  1442.  
  1443.             (print "Hello there" fp)
  1444.  
  1445.         Evaluating this expression will result in the string "Hello
  1446.         there" being written to the file "test.dat".  More data can be
  1447.         written to the file using a similar technique.
  1448.  
  1449.         Once you are done writing to the file, you should close it.
  1450.         Closing an output file is just like closing an input file.
  1451.  
  1452.             (close fp)
  1453.  
  1454.         Evaluating this expression will close the output file and make
  1455.         it permanent.
  1456.  
  1457.  
  1458.         XLISP                       EXAMPLES                     Page 43
  1459.  
  1460.         A Slightly More Complicated File Example
  1461.  
  1462.         This example shows how to open a file, read each Lisp expression
  1463.         from the file and print it.  It demonstrates the use of files
  1464.         and the use of the optional "stream" argument to the READ
  1465.         function.
  1466.  
  1467.             (do* ((fp (openi "test.dat"))
  1468.                   (ex (read fp) (read fp)))
  1469.                  ((null ex) nil)
  1470.               (print ex))
  1471.